1. Field of the Invention
The present invention relates to a serial communication system, and more particularly to correction of a baud rate in serial communication.
2. Description of Related Art
Recently, there has been a wide spread of a control system onboard network for connecting ECUs (Electronic Control Units) which are mounted on automobiles. As the communication protocols of a typical control system onboard network system, there are CAN (Controller Area Network), LIN (Local Interconnect Network), and FlexRAY. The CAN is mainly employed as a standard specification of a power train system network or a chassis system network. The LIN is employed as a standard specification of a body system serial communication network that is used at a relatively low speed (transmission rate of 1 to 20 kbps). Further, the FlexRAY is standardized to correspond to X-by-wire applications.
The LIN is a serial communication protocol that has been standardized by the LIN consortium for achieving communication with high cost performance between various sensors and actuators having a high-grade function in an onboard network system. The LIN is used for communication between apparatuses which do not require as much band widths and versatility as the CAN does. For example, it is used as a communication path for supplying data to the CAN from various sensors. Further, it is lower at cost compared to the CAN and the FlexRAY.
In the standard of LIN, used is an UART (Universal Asynchronous Receiver Transmitter) interface that has already become popular as a communication system. Network topology is not specifically defined for the LIN, but bus topology is employed basically. The LIN includes a single master node and a plurality of slave nodes, which are connected mutually via a bus. Currently, the maximum number of slave nodes that can be connected to a single master node is defined as fifteen. A micro controller unit provided with a CPU is an example of the master node and slave nodes. In the master node, a program for executing a master task and a program for executing a slave task are stored in a storage unit. The master task is a task that determines the transfer timing and transfer destination of frames. The slave task prepares a data field for transfer by each frame. The slave node executes only the slave task, so that the slave task program is stored in the storage unit thereof. The master program may be stored in the storage unit of the slave node. It is easy to control a program so as not to execute the master program when operating as the slave node. The CPU of the master node executes the master task to transmit a frame header to the slave node. The CPU of the slave node executes the slave task to respond to the frame header, and transmits a response (including a data field). The master node can also execute the slave task, so that it can transmit a response including the data field after transmission of the header.
The frame header transmitted from the master node to the slave node includes a synch brake field (brake field), a synch field (synchronous byte), and an ID field (protection ID) in order. Further, following the header, a response including a data filed of 8 bytes at the maximum and a checksum of 1 byte is transferred. The brake field is composed of a low level (dominant level) of 13 bits or more. The synch field has 0x55 data value of 8 bits. The ID field is constituted with ID of 6 bits and parity of 2 bits.
An access system of the LIN is a time trigger system. Thus, a message sequence is set in the master task in advance as a transfer schedule. The master node can manage the network by executing an application as LIN clusters. That is, all the tasks within the LIN are managed on the basis of time, so that there is no collision between messages as long as synchronization is maintained.
The establishment of synchronization in the LIN is to correct the period of sampling clocks for obtaining or transmitting serial data to meet with the reference period. Normally, a baud rate of the slave node is corrected to coincide with a baud rate of the master node to achieve synchronization. The slave node corrects the baud rate based on the reference clock (synch field) transmitted from the master node. Correction of the baud rate is performed every time a header arrives.
A baud rate correcting method according to a conventional technique will be described by referring to FIG. 1. FIG. 1 is a block diagram showing the configuration of a baud rate generator 120 according to the conventional technique. The baud rate generator 120 in the slave node according to the conventional technique corrects the baud rate by executing software for baud rate correction. More specifically, the baud rate generator 120 includes a baud rate initial value setting register 126 for storing a baud rate set value 135, a counter 128 which counts system clocks 1101 generated by a clock generator 111, and outputs the number as a counter value 137, and a coincidence detecting circuit 129 that outputs a coincidence detecting signal 138 to an I/O interface 140. The coincidence detecting signal 138 is used for determining the baud rate at a timing where the baud rate set value 135 and the counter value 137 are coincident with each other. The baud rate set value 135 is calculated by an arithmetic operation of a CPU 110, and it is ½-bit period time (a half of the time of 1 bit), for example. The CPU 110 of the slave node executes an interruption process for correcting the baud rate in response to the synch brake field supplied from the master node. In this interruption process, the CPU 110 starts up a timer placed outside the serial communication circuit, measures the period of the synch field, and calculates the baud rate set value 135 from the measured result. At that time, the CPU 110 stops the serial communication, resets the baud rate set value 135 to the baud rate initial value setting register 126, and corrects the baud rate. The CPU 110 restarts the serial communication after correcting the baud rate. As described, the slave node according to the conventional technique temporarily terminates the communication process, and corrects the baud rate through the arithmetic operation performed by the CPU 110.
Further, as a related art, Japanese Laid Open Patent Publication (JP-P2001-069194A) discloses a baud rate setting method in serial communication. In the baud rate setting method described of the related art, the predetermined pulse width of a pulse signal is counted by a timer, and the operation frequency of an apparatus is calculated from the count value. Then, the baud rate is set in accordance with the calculated operation frequency. At that time, a relation φ=(n×m)/T″ is met, where the pulse width is T, the CPU operation frequency within the apparatus is φ, the frequency dividing ratio of the timer with respect to the CPU operation frequency φ is n, and a counter value of the timer is m. Therefore, the operation frequency φ is calculated and resetting of the baud rate is performed.
In baud rate correction according to the conventional technique, the CPU of the slave node executes the software for baud rate correction. When measuring the period of the synch field, it is necessary to start up a timer placed outside the serial communication circuit. Further, the baud rate correction set value, for example, ½-bit period time is calculated through the arithmetic processing by the CPU, by using the measured result of the synch field period. Thus, when the baud rate correction is performed, there is a large load imposed upon the CPU, and it is required to perform processes such as starting up the timer outside the serial communication circuit and stopping the serial communication circuit. Since it requires time to perform such processes, a wait time from the synch field to the ID field needs to be set longer. This deteriorates the transfer speed.
In the method described in Japanese Laid Open Patent Publication (JP-P2001-069194A), the operation frequency is calculated by measuring the pulse width. However, in the LIN, since the low level and the high level continue alternately in the synch field having the 0x55 data, an accurate baud rate based on the protocol cannot be determined even if the low level width of one bit is calculated. Further, there is no guarantee that the pulse width T can be divided by a timer period t with no remainder, so that the calculated operation frequency includes an error. Therefore, it is not suitable for finely adjusting the baud rate error that is generated due to a difference in the operation frequency between the master node and the slave node. Furthermore, this method employs incrementing the counter value m in an interruption process performed for every timer period t, which increases a load imposed upon the CPU.